/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2023-11-14 17:15:35
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2023-11-24 21:33:08
 * @FilePath: /three-react/src/pages/Camera/Camera1.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { useEffect, useRef } from "react"
import createRender from '@/createRender';
import * as THREE from 'three'

const state = {}
export default function Page() {
  
  const container = useRef(null);
  useEffect(() => {
    if (!state.isMounted) {
      createRender(container)(render);
      state.isMounted = true;
    }
  }, [])

  function render(scene, camera, renderer) {
    
    const radius = 100;
    const geometry = new THREE.CircleGeometry(radius,12)
    const material = new THREE.MeshLambertMaterial({
      color: 0x00ffff,
      wireframe: true,
    })
    const mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh)


    const geometry1 = new THREE.SphereGeometry(5);
    const material1 = new THREE.MeshLambertMaterial({
      color: 0x00ff00
    })

    const angle = Math.PI/6;
    // const mesh1 = new THREE.Mesh(geometry1, material1)
    // const x = radius * Math.cos(angle);
    // const y = radius * Math.sin(angle);
    // mesh1.position.set(x, y, 0)
    // scene.add(mesh1);



    // demo
    for (let index = 0; index < 2; index++) {
      const sphere = new THREE.Mesh(geometry1, material1);
      const x = radius * Math.cos(angle*index);
      const y = radius * Math.sin(angle*index);
      sphere.position.set(x, y, 0)
      scene.add(sphere);
      
    }
  }

  return (
    <div id="container" className="full container" ref={container}></div>
  )
}